// LSL script generated: RLV-New.RLV_MENU.DV_RLV_MoveTP.lslp Sun May  2 00:09:51 Westeuropäische Sommerzeit 2010
/*
################################################################################################################################# Included
0 3    B  Allow/prevent teleporting to a landmark : "@tplm=<y/n>"          
1 3    B  Allow/prevent teleporting to a location : "@tploc=<y/n>"  
2 3    B  Allow/prevent teleporting by a friend, secure way : "@tplure_sec=<y/n>"
3 3    B  Unlimit/limit sit-tp : "@sittp=<y/n>"               
4 3    B  Allow/prevent standing up : @unsit=<y/n>     
5 3    B  Allow/prevent sitting down : @sit=<y/n>
6 3    B  Allow/prevent flying : @fly=<y/n> 

#################################################################################################################################
*/
integer attachment = 1;
string cmdname;
key victim;
list gMenu = [];
list statesMenu = [0,0,0,0,0,0,0,0];
key ToucherID;
integer channel_dialog;
integer listen_id;
string msg = "Move / TP";
list sideMenu = [" ","Back"," "];

llRlvSay(string command){
    if ((attachment == 1)) {
        llOwnerSay(("@" + command));
    }
    else  {
        llSay(-1812221819,(((((cmdname + ",") + ((string)victim)) + ",") + "@") + command));
    }
}

MakeRLVState(){
    if ((attachment == 1)) {
        if ((llList2Integer(statesMenu,0) == 1)) llRlvSay("tplm=n");
        if ((llList2Integer(statesMenu,1) == 1)) llRlvSay("tploc=n");
        if ((llList2Integer(statesMenu,2) == 1)) llRlvSay("tplure_sec=n");
        if ((llList2Integer(statesMenu,3) == 1)) llRlvSay("sittp=n");
        if ((llList2Integer(statesMenu,4) == 1)) llRlvSay("unsit=n");
        if ((llList2Integer(statesMenu,5) == 1)) llRlvSay("sit=n");
        if ((llList2Integer(statesMenu,6) == 1)) llRlvSay("fly=n");
    }
}

llLRP(integer element_new,integer placeinlist){
    (statesMenu = llListReplaceList(statesMenu,[element_new],placeinlist,placeinlist));
}

makeMenu(){
    (gMenu = []);
    (gMenu += sideMenu);
    if ((llList2Integer(statesMenu,0) == 1)) (gMenu += "[x]TP LM");
    else  (gMenu += "[ ]TP LM");
    if ((llList2Integer(statesMenu,1) == 1)) (gMenu += "[x]TP Location");
    else  (gMenu += "[ ]TP Location");
    if ((llList2Integer(statesMenu,2) == 1)) (gMenu += "[x]TP Friend");
    else  (gMenu += "[ ]TP Friend");
    if ((llList2Integer(statesMenu,3) == 1)) (gMenu += "[x]Far Sit");
    else  (gMenu += "[ ]Far Sit");
    if ((llList2Integer(statesMenu,4) == 1)) (gMenu += "[x]Stand");
    else  (gMenu += "[ ]Stand");
    if ((llList2Integer(statesMenu,5) == 1)) (gMenu += "[x]Sit");
    else  (gMenu += "[ ]Sit");
    if ((llList2Integer(statesMenu,6) == 1)) (gMenu += "[x]Fly");
    else  (gMenu += "[ ]Fly");
    (channel_dialog = (-1 * ((integer)("0x" + llGetSubString(((string)llGetKey()),-5,-1)))));
    (listen_id = llListen(channel_dialog,"",NULL_KEY,""));
    llDialog(ToucherID,msg,gMenu,channel_dialog);
    llSetTimerEvent(45.0);
}

default {

    state_entry() {
    }

    
    listen(integer channel,string name,key id,string message) {
        llListenRemove(listen_id);
        llSetTimerEvent(0.0);
        if ((message == "[x]TP LM")) {
            llLRP(0,0);
            llRlvSay("tplm=y");
            makeMenu();
        }
        if ((message == "[ ]TP LM")) {
            llLRP(1,0);
            llRlvSay("tplm=n");
            makeMenu();
        }
        if ((message == "[x]TP Location")) {
            llLRP(0,1);
            llRlvSay("tploc=y");
            makeMenu();
        }
        if ((message == "[ ]TP Location")) {
            llLRP(1,1);
            llRlvSay("tploc=n");
            makeMenu();
        }
        if ((message == "[x]TP Friend")) {
            llLRP(0,2);
            llRlvSay("tplure_sec=y");
            makeMenu();
        }
        if ((message == "[ ]TP Friend")) {
            llLRP(1,2);
            llRlvSay("tplure_sec=n");
            makeMenu();
        }
        if ((message == "[x]Far Sit")) {
            llLRP(0,3);
            llRlvSay("sittp=y");
            makeMenu();
        }
        if ((message == "[ ]Far Sit")) {
            llLRP(1,3);
            llRlvSay("sittp=n");
            makeMenu();
        }
        if ((message == "[x]Stand")) {
            llLRP(0,4);
            llRlvSay("unsit=y");
            makeMenu();
        }
        if ((message == "[ ]Stand")) {
            llLRP(1,4);
            llRlvSay("unsit=n");
            makeMenu();
        }
        if ((message == "[x]Sit")) {
            llLRP(0,5);
            llRlvSay("sit=y");
            makeMenu();
        }
        if ((message == "[ ]Sit")) {
            llLRP(1,5);
            llRlvSay("sit=n");
            makeMenu();
        }
        if ((message == "[x]Fly")) {
            llLRP(0,6);
            llRlvSay("fly=y");
            makeMenu();
        }
        if ((message == "[ ]Fly")) {
            llLRP(1,6);
            llRlvSay("fly=n");
            makeMenu();
        }
        if ((message == "Back")) llMessageLinked(-4,1337,"DV_MAIN_RLV",ToucherID);
    }

    
    on_rez(integer on) {
    }

    
    link_message(integer sender,integer num,string str,key id) {
        if ((num == 1337)) {
            if ((str == llGetScriptName())) {
                llMessageLinked(-4,1338,llGetScriptName(),NULL_KEY);
                (ToucherID = id);
                makeMenu();
            }
        }
        if ((num == 1338)) {
            if ((str == "attachment")) (attachment = 1);
            else  if ((str == "device")) (attachment = 0);
            else  if ((str != llGetScriptName())) {
                llListenRemove(listen_id);
            }
        }
        if ((num == 1339)) {
            if ((str == "ON_REZ")) {
                MakeRLVState();
            }
            if ((str == "RESET")) {
                (statesMenu = [0,0,0,0,0,0,0,0]);
            }
        }
        if ((num == 1329)) {
            (victim = ((key)str));
            (cmdname = ((string)llGetKey()));
        }
    }

  	
  	timer() {
        llSetTimerEvent(0.0);
        llListenRemove(listen_id);
    }
}
